import com.adobe.cairngorm.control.CairngormEventDispatcher;

import mx.events.CloseEvent;
import mx.managers.PopUpManager;

import net.optix.ip.events.UpdateBasicInventionEvent;
import net.optix.ip.events.UpdateInventionEvent;
import net.optix.ip.model.ModelLocator;
import net.optix.ip.vo.InventionVO;
            
[Bindable]
public var model:ModelLocator	=	ModelLocator.getInstance(); 
  
private function titleWindow_close(evt:CloseEvent):void 
{ 
	model.result	=	"";
            	model.bSubmit	=	true;
                PopUpManager.removePopUp(this); 
            }
            
            public function init():void
  			{
  				model.bSubmit	=	true;
  				model.result	=	"";
  				model.close		=	"no";
  			}
  			
            public function addInvention():void
            {	
            	var result:Boolean	=	true;
            	
            	model.bSubmit	=	false;
            	
            	if(title1.text == "")
            	{
            		resultTitle.text	=	"This field is required";
            		result	=	false;
            	}
            	else
            	{
            		resultTitle.text	=	"";
            	}

            	if(result == true)
            	{
	            	var vo:InventionVO	=	model.currentInvention;
	            	vo.title	=	title1.text;
	            	vo.keyWords	=	keyWords.text;
	            	vo.docket	=	docket.text;
	            	vo.description	=	description.text;
					
					var event:UpdateInventionEvent	=	new UpdateInventionEvent(vo);
	            	CairngormEventDispatcher.getInstance().dispatchEvent(event);
	            }
	            else
	            {
	            	model.bSubmit	=	true;
	            }
            }
            
            public function clear():void
            {
            	
            }